<?php
/**
 * Log.php                 系统日志模型
 *
 * @author                  mashanling <msl-138@163.com>
 * @date                    2012-12-26 15:01:44
 * @lastmodify             2012-12-26 15:01:44 by mashanling
 */

class LogModel extends BaseModel {
    protected $_auto = array(//自动填充
        'log_time'     => 'gmtime',
        'admin_ip'     => 'get_client_ip#1',
        'admin_id'     => '_getAdminId',
        'admin_name'   => '_getAdminName',
        'page_url'     => '_getPageUrl',
        'referer_url'  => '_getRefererUrl',
    );
    protected $_db_fields = array (
        'log_id'         => null,//自增id
        'content'        => null,//日志内容
        'log_type'       => null,//日志类型
        'log_time'       => null,//日志时间
        'page_url'       => null,//日志页面
        'referer_url'    => null,//来路页面
        'admin_ip'   	 => null,//管理员ip
        'admin_id'   	 => null,//管理员id
        'admin_name'     => null,//管理员姓名
    );
    protected $_pk_field = 'log_id';//主键
    protected $_true_table_name = TB_LOG;//表

    /**
     * 获取管理员姓名
     *
     * @access protected
     *
     * @author          mashanling <msl-138@163.com>
     * @date            2012-07-09 11:11:54
     * @lastmodify     2012-12-26 15:03:10 by mashanling
     *
     * @return string 管理 员姓名
     */
    protected function _getAdminName() {
        $admin_info = Yaf\Registry::get(SESSION_ADMIN_KEY);

        return $admin_info ? $admin_info['realname'] : '';
    }
}